package StreamDemo.demo1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public class test4 {
    public static void main(String[] args){
        ArrayList<String> list2 = new ArrayList<>();
        Collections.addAll(list2,"张无忌-男-14","张强-男-18","张三丰-女-19","张翠山-女-20","张良-男-30","王二麻子-男-90","谢广坤-20");
        Map<String,Integer> set = list2.stream()
        .filter(s -> "男".equals(s.split("-")[1])).collect(Collectors.toMap(s -> s.split("-")[0],v -> Integer.parseInt(v.split("-")[2])));
        System.out.println(set);
    }
}
